#!/usr/bin/env python3

import sys
import datetime
import os
import subprocess
import re  # 正则
import os.path

print("update chk,repos status ready")

work_space_root="/home/nio/repos"

#-------------------git chk and update-----------------------------
map_engine_repo_dir_arm_cosine      =work_space_root+"/map_engine_src/map_engine_sud_provider_cosine"
map_engine_repo_dir_x86             =work_space_root+"/map_engine_lib_repo/map_engine_sdk"
map_engine_repo_dir_arm_cyber       =work_space_root+"/map_engine_src/map_engine_for_arm_lib"
localization_ext_repo_dir           =work_space_root+"/localization_external"

print("map_engine_repo_dir_arm_cosine")
os.system('\
          cd %s &&\
          git fetch --all &&\
          git checkout jianxiao_cosine_orin &&\
          git status &&\
          git reset --hard origin/jianxiao_cosine_orin &&\
          git submodule update --init --recursive \
          '%(\
            map_engine_repo_dir_arm_cosine\
              ))


print("map_engine_repo_dir_x86")
os.system('\
          cd %s &&\
          git fetch --all &&\
          git checkout master &&\
          git status &&\
          git pull \
          '%(\
            map_engine_repo_dir_x86\
              ))

print("map_engine_repo_dir_arm_cyber")
os.system('\
          cd %s &&\
          git fetch --all &&\
          git checkout jianxiao_sud_test &&\
          git status &&\
          git pull &&\
          git checkout yuhongsong/base_on_jianxiao_sud_test &&\
          git rebase origin/jianxiao_sud_test \
          '%(\
            map_engine_repo_dir_arm_cyber\
              ))



print("localization_external repo")
os.system('\
          cd %s &&\
          git fetch --all &&\
          git checkout feature/update_map_engine_sdk &&\
          git checkout -- . &&\
          git clean -xdf &&\
          git rebase origin/master &&\
          git status &&\
          git tag --sort=-v:refname \
          '%(\
            localization_ext_repo_dir\
              ))

#-------------------git chk and update-----------------------------